﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BGCOP.CAVTOP.WINFORMS.frmtlk;
using Telerik.WinControls.UI.Export;
using Telerik.WinControls.UI.Localization;

namespace BGCOP.CAVTOP.WINFORMS
{
    public partial class frmAsignaParqueo2 : Form
    {
        public frmAsignaParqueo2()
        {
            InitializeComponent();
        }

        private void tvehiculoParqueoBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Desea realizar las operaciones pendientes?", Properties.Settings.Default.Titulo,
               MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
            {
                this.Validate();
                this.tvehiculoParqueoBindingSource.EndEdit();
                this.tableAdapterManager.UpdateAll(this.masterDBACDataSet);
                MessageBox.Show("El registro se proceso con exito!", Properties.Settings.Default.Titulo
                                , MessageBoxButtons.OK);
            }
        }

        private void frmAsignaParqueo2_Load(object sender, EventArgs e)
        {
            tInicio.Enabled = true;
        }

        private void radGridView1_CellBeginEdit(object sender, Telerik.WinControls.UI.GridViewCellCancelEventArgs e)
        {
            e.Row.Cells["diaSemana"].Value = 1;
            e.Row.Cells["fechaUltimaGestion"].Value = DateTime.Now;
            e.Row.Cells["usuarioUltimaGestion"].Value = BGCOP.CAVTOP.WINFORMS.Program.idUsuarioActual;
        }

        private void tInicio_Tick(object sender, EventArgs e)
        {
            tInicio.Enabled = false;
            // TODO: This line of code loads data into the 'masterDBACDataSet.TParqueo' table. You can move, or remove it, as needed.
            this.tParqueoTableAdapter.Fill(this.masterDBACDataSet.TParqueo);
            // TODO: This line of code loads data into the 'masterDBACDataSet.TVehiculo' table. You can move, or remove it, as needed.
            this.tVehiculoTableAdapter.Fill(this.masterDBACDataSet.TVehiculo);
            // TODO: This line of code loads data into the 'masterDBACDataSet.TvehiculoParqueo' table. You can move, or remove it, as needed.
            this.tvehiculoParqueoTableAdapter.Fill(this.masterDBACDataSet.TvehiculoParqueo);
            //RadGridLocalizationProvider.CurrentProvider = new MyEnglishRadGridLocalizationProvider();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ExportToExcelML exporter = new ExportToExcelML(this.radGridView1);
            exporter.HiddenColumnOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport;
            exporter.ExportVisualSettings = true;
            exporter.SheetMaxRows = ExcelMaxRows._1048576;
            exporter.SheetName = "Listado";
            exporter.SummariesExportOption = SummariesOption.DoNotExport;
            string ruta;
            ruta = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\ExportedDataAsignacionParqueos.xls";
            try
            {
                exporter.RunExport(ruta);
                radDesktopAlert1.ContentImage = BGCOP.CAVTOP.WINFORMS.Properties.Resources.File_Excel_icon;
                radDesktopAlert1.CaptionText = "Exportar a excel";
                radDesktopAlert1.ContentText = "El archivo se exportado con exito.\r\nRuta: " + ruta;
                radDesktopAlert1.FixedSize = new Size(450, 150);
                radDesktopAlert1.Show();
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.ToString());
            }
        }
    }
}
